package com.example.com.test.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.com.test.R;
import com.example.com.test.view.MarqueeView;

/**
 * 作者： njb
 * 时间： 2018/12/21 13:04
 * 描述：
 * 来源：
 */
public class MarqueeTextActivity extends AppCompatActivity {
    private MarqueeView tvMarquee;
    private TextView tvProfitOne,tvProfitTwo,tvProfitThree,tvProfitFour,tvProfitFive;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_marquee);
        initView();
        initMarqueeView();
    }


    private void initView() {
        TextView textView = findViewById(R.id.tv_marquee);
        tvMarquee = findViewById(R.id.marquee_view);
        textView.setFocusable(true);
        textView.requestFocus();
    }

    private void initMarqueeView() {
        View view = (LayoutInflater.from(this).inflate(R.layout.scroll_textview, null));
        tvMarquee.addViewInQueue(view);


        tvProfitOne = view.findViewById(R.id.tv_profit_one);
        tvProfitTwo = view.findViewById(R.id.tv_profit_two);
        tvProfitThree = view.findViewById(R.id.tv_profit_three);
        tvProfitFour = view.findViewById(R.id.tv_profit_four);
        tvProfitFive = view.findViewById(R.id.tv_profit_five);



        tvMarquee.requestFocus();//获取焦点
        tvMarquee.setScrollSpeed(5);//滚动速度
        tvMarquee.setScrollDirection(MarqueeView.RIGHT_TO_LEFT);//滚动方向
        tvMarquee.setViewMargin(15);//按钮间隔
        tvMarquee.startScroll();

    }
}
